package erfgame.core.graphics.renderer;

import java.util.Map;


import erfgame.core.Rotation;
import erfgame.core.entity.Entity;
import erfgame.core.entity.State;
import erfgame.core.entity.StatefulEntity;
import erfgame.core.world.World;

public class StatefulEntityRendererFactory implements EntityRendererFactory {
	
	private Map<State, EntityRenderer> renderers;
	private EntityRenderer defaultRenderer;
	
	private StatefulEntityRendererFactory( Map<State, EntityRenderer> renderers, EntityRenderer defaultRenderer ) {
		this.renderers = renderers;
		this.defaultRenderer = defaultRenderer;
	}

	public EntityRenderer getRenderer(World world, Entity entity, Rotation viewRotation) {
		return new StatefulEntityRenderer(
				world, 
				(StatefulEntity)entity, 
				renderers, 
				((PrototypeEntityRenderer)defaultRenderer).spawn(world, entity)
		);
	}

}
